package com.spyx.test;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Demo1 {
    public static void main(String[] args) {
        //1.创建线程池，内部有3个线程
        ExecutorService executorService = Executors.newFixedThreadPool(3);
        System.out.println("main begin....");
        //2.参数1 是线程的任务内容   参数2 线程池对象
        // CompletableFuture.runAsync() 指定让线程做某件事，但是不返回结果
        CompletableFuture<Void> completableFuture =
                CompletableFuture.runAsync(()->{
                    System.out.println("当前线程："+Thread.currentThread());
                    int result = 1024;
                    System.out.println("result:"+result);
                },executorService);
        System.out.println("main over....");
    }
}
